#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
// prority_queue<int, vecotr<int>, greater<int>> pq;

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> ans;
    ans.push_back(a[0]);
    for(int i = 1; i <n; i++) {
        if(a[i] >= a[i - 1]){
            ans.push_back(a[i]);
        }else{
            ans.push_back(a[i]);
            ans.push_back(a[i]);
        }
    }
    cout << ans.size() << endl;
    for(auto x : ans) cout << x << ' ';
    cout << endl;
}

signed main() {
    int t; cin >> t;
    while(t--) solve();
    return 0;
}